package com.yuyou.activity.comm.service.tool;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.mail.MailException;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Service;

@Service
public class MailUtil {

	private final Logger logger = LoggerFactory.getLogger(this.getClass());  
	
	@Autowired
	JavaMailSender mailSender;

	@Value("${mail.open}")
	private  String open;
	
	public void sendEmail(String subject ,String content) {
		if(open.equals("on")){
			try {
				SimpleMailMessage message = new SimpleMailMessage();
				message.setFrom("zymonitor123@163.com");
				message.setTo("zymonitor123@163.com");
				message.setSubject(subject);
				message.setText(content);
				mailSender.send(message);
			} catch (MailException e) {
				logger.error("send mail error：",e);
			}
		}
	}

	
	
	
	
	
	
	
	
	
	
	
	
	
	
}
